export function convertUTCToGMTString (date){
    const currentDate = new Date(date);
    const month = currentDate.getMonth()<9? `0${currentDate.getMonth() + 1}` : currentDate.getMonth().toString();
  return `${currentDate.getFullYear()}-${month}-${currentDate.getDate()}`;
}

export function generateNewDate (){
  const currentDate = new Date();
  const month = currentDate.getMonth()<9? `0${currentDate.getMonth() + 1}` : currentDate.getMonth().toString();
  return `${currentDate.getFullYear()}-${month}-${currentDate.getDate()}`;
}

export function getMiddleDate (date1, date2) {
  return new Date(date2 - (date2 - date1)/2).toLocaleDateString();
}

export function isMidMonth (date1, date2) {
  const middleDate = getMiddleDate(date1, date2);
  const middleDateSplits = middleDate.split('/');
  const currentDateSplits = new Date().toLocaleDateString().split('/');

  if (middleDateSplits[0] == currentDateSplits[0] && middleDateSplits[1] == currentDateSplits[1]) {
    return true;
  }
  
  return false;
}

export function getMinusDate (date1, date2) {
  return date2 - date1 > 0? date2 : date1;
}

export function getMidEndDate (date1, date2) {
  const midData = new Date(getMiddleDate(new Date(date1), new Date(date2)));
  const addMoreDays = new Date(midData.setDate(midData.getDate() + 10));

  return getMinusDate(addMoreDays, date2);
}

export function isLastMonth (date) {
  const lastDateSplits = date.toLocaleDateString().split('/');
  const currentDateSplits = new Date().toLocaleDateString().split('/');

  if (lastDateSplits[0] == currentDateSplits[0] && lastDateSplits[1] == currentDateSplits[1]) {
    return true;
  }
  
  return false;
}